<template>
  <div class="icons-wrapper">
    <swiper :options="swiperoption">
      <swiper-slide v-for="(page, index) in pages" :key="index">
        <div class="icon" v-for="item in page" :key="item.id">
          <img class="icon-img" :src="item.iconUrl" alt="">
          <p class="icons-text">{{ item.tradText }}</p>
        </div>
      </swiper-slide>
    </swiper>
  </div>
</template>

<script>
export default {
  name: 'HomeIcons',
  props: {
    iconList: Array
  },
  data () {
    return {
      swiperoption: {}
    }
  },
  computed: {
    pages () {
      const pages = []
      this.iconList.forEach((item, index) => {
        const page = Math.floor(index / 8)
        if (!pages[page]) {
          pages[page] = []
        }
        pages[page].push(item)
      })
      return pages
    }
  }
}
</script>

<style lang="stylus" scoped>
  @import '~styles/varibles.styl'
  @import '~styles/mixins.styl'
  .icons-wrapper
    margin-top: .1rem
    background-color: #fff
    .icon
      display: flex
      flex-direction: column
      justify-content: center
      align-items: center
      overflow: hidden
      width: 25%
      float: left
      padding: .20rem 0
      .icon-img
        width: 50%
      .icons-text
        padding-top: .1rem
        font-size: .25rem
        color: $baseTextColor
        ellipsis()
</style>
